import { reqDetailInfo } from "@/api"

export default {
    state: {
        detailInfo:{}
    },
    mutations: {
        UPDATE_DETAILINFO(state, detailInfo) {
            state.detailInfo = detailInfo
        }
    },
    actions: {
        async getDetailInfo({ commit }, skuId) {
            const res = await reqDetailInfo(skuId)
            if (res.code === 200) {
                commit('UPDATE_DETAILINFO',res.data)
            }
        }
    },
    getters: {
        categoryView(state) {
            return state.detailInfo.categoryView || {}
        },
        skuInfo(state) {
            return state.detailInfo.skuInfo || {}
        },
        spuSaleAttrList(state) {
            return state.detailInfo.spuSaleAttrList || []
        }
    }
}